﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;

namespace ModelLayer
{
    [DataContract]
    [KnownType(typeof(Customer))]
    public class Travel
    {
        [DataMember]
        public int TravelId { get; set; }
        [DataMember]
        public Airport StartDestination { get; set; }
        [DataMember]
        public Airport EndDestination { get; set; }
        [DataMember]
        public double TotalPrice { get; set; }
        [DataMember]
        public List<Customer> Persons{ get; set; }
        [DataMember]
        public List<SeatBooking> SeatBooks{ get; set; }


        public Travel()
        {
            Persons = new List<Customer>();
            SeatBooks = new List<SeatBooking>();
        }
        //Overrides equals to compare Travels based on their id
        public override bool Equals(object _obj)
        {
            bool equal = false;
            Travel objTravel = (Travel)_obj;

            if (TravelId.Equals(objTravel.TravelId))
            {
                equal = true;
            }
            return equal;
        }
        //Overrides the string representation of the object
        public override string ToString()
        {
            return string.Format("Start destination: {0} \n End destination: {1} \n Total price: {2}", StartDestination, EndDestination, TotalPrice);
        }
    }
}

